﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevExpress.Utils;
using DevTeam;
using System;
using System.Drawing;

namespace ConfExpert.Forms.Depo._7C
{
    public partial class BedenDagilimTrendi : XForm
    {
        int CKBatchId = -1;
        public BedenDagilimTrendi(int ckBatchId)
        {
            InitializeComponent();
            this.CKBatchId = ckBatchId;
            this.Text += "- " + AppSession.Lookups.CKBatch.FindByCKBatchId(CKBatchId).Notes;
        }

        private void BedenDagilimTrendi_Load(object sender, EventArgs e)
        {
            
            gridView1.Init("Get7cBedenler", CKBatchId, string.Empty);
            gridView1.FormatAsNumber(1,"B01","B02","B03","B04","B05","B06","B08","B10","B12","D38","D40","D42","D44","D46","D48","D50","D52","D54","D56","D58","D60","U36","U37","U38","U39","U40","U41","U42","U43","U44","U45","U46","U47","U48","U49","U50","U51","U52","U53","U54");
            gridView1.FormatAsNumber(0,"Total");
            gridView1.AddSummary("Total");
            gridView1.MakeReadOnly();
            gridView1.DoubleClick += gridView1_DoubleClick;
            gridView1.RowCellStyle += gridView1_RowCellStyle;
            gridView1.MakeRowSelectable();
            gridView1.BestFitColumns();
        }

        void gridView1_DoubleClick(object sender, EventArgs e)
        {
            string model = gridView1.GetFocusedDataRow()["BareModel"].ToString();
            string linea = gridView1.GetFocusedDataRow()["Linea"].ToString();
            using (BedenDagilimTrendiModel m = new BedenDagilimTrendiModel(model, linea))
                m.ShowDialog();
        }

        void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.Column.FieldName.EndsWith("Model"))
                e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
        }

    }
}
